package com.dcits.dubbo.provider;

import com.alibaba.dubbo.config.annotation.Service;
import com.dcits.api.ApiService;
import com.dcits.api.entity.ApiInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

@Service(version = "1.0.0",timeout = 3000,loadbalance = "random")
public class ApiServiceImpl implements ApiService {

    private static Logger logger = LoggerFactory.getLogger(ApiServiceImpl.class);

	@Override
    public String sayHello(String name) {

	    return "Hello, " + name + ", " + new Date();

    }

    @Override
    public ApiInfo GetApiInfo(ApiInfo info){

	    String ApiName = info.getApiName();

	    if(null == ApiName){
	        if(logger.isInfoEnabled()){
                logger.info("入参为空");
            }

            ApiName = "Dubbo测试";

            info.setApiCode("000000");
            info.setApiDesc("Dubbo测试接口");
            info.setServiceCode("30010BB000302");
            info.setServiceMsg("Dubbo测试服务");
            info.setServiceNo(1);
            info.setApiName(ApiName);

        }else{

            info.setApiCode("000000");
            info.setApiDesc("Dubbo测试接口");
            info.setServiceCode("30010BB000301");
            info.setServiceMsg("Dubbo测试服务");
            info.setServiceNo(2);
            info.setApiId("API_001");
        }

        if(logger.isInfoEnabled()){
            logger.info("将返回的API信息为："+info);
        }
        return info;
    }
}